const a = require('./a');
const b = require('./b');

console.log(a.add(1, 2))
b();
console.log(a);
console.log(b);

const fs = require('fs')

let path = require('path');
const { resolve } = require('path');
const { rejects } = require('assert');

let hello01 = path.resolve(__dirname, 'hello01.txt');


fs.readFile(hello01, 'utf8', (error, data) => {
    console.log(data.toString())
})


function fsRead(filePath) {
    return new Promise((resolve, reject) => {
        filePath = path.resolve(__dirname, filePath);
        fs.readFile(filePath, 'utf8', (error, data) => {
        
            if (error) {
                reject('read fail');
            }
            if (data) {
                resolve(data);
            }

        })
    })

}

async function readFileList() {
    let file1 = await fsRead('hello01.txt');
    console.log('1:' + file1.toString())

    let file2 = await fsRead('hello02.txt');
    console.log('2:' + file2.toString())

    let file3 = await fsRead('hello03.txt');
    console.log('3:' + file3.toString())

}

readFileList();